<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JsUnit Tests</title>
    <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
    <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../lib/MJ.js"></script>
    <script language="JavaScript" type="text/javascript">
        function testIsSanankou1() {
            var tehai = new MJ.Tehai();
	    tehai.addAll(["5m", "5m", "5m", "1s", "1s", "1s",
	                  "3s", "3s", "3s", "7p", "7p", "7p",
			  "9p", "9p"], "7p");
            var agari_pattern = tehai.getAgariPattern();
	    assertTrue(MJ.Hantei._2Han.isSanankou(agari_pattern[0]));
        }

        function testIsSanankou2() {
            var tehai = new MJ.Tehai();
	    tehai.addAll(["5m", "5m", "5m", "1s", "1s", "1s",
	                  "3s", "3s", "3s", "3p", "4p", "5p",
			  "9p", "9p"], "5p");
            var agari_pattern = tehai.getAgariPattern();
	    assertTrue(MJ.Hantei._2Han.isSanankou(agari_pattern[0]));
        }

        function testIsSanankou3() {
            var tehai = new MJ.Tehai();
	    tehai.addAll(["5m", "5m", "5m", "1s", "2s", "3s",
	                  "3s", "3s", "3s", "7p", "7p", "7p",
			  "9p", "9p"], "7p");
            var agari_pattern = tehai.getAgariPattern();
	    assertTrue(MJ.Hantei._2Han.isSanankou(agari_pattern[0]));
        }

        function testIsSanankou4() {
            var tehai = new MJ.Tehai();
	    tehai.addAll(["5m", "6m", "7m", "1s", "2s", "3s",
	                  "3s", "3s", "3s", "7p", "7p", "7p",
			  "9p", "9p"], "7p");
            var agari_pattern = tehai.getAgariPattern();
	    assertFalse(MJ.Hantei._2Han.isSanankou(agari_pattern[0]));
        }

        function testIsSanankou5() {
            var tehai = new MJ.Tehai();
	    tehai.addAll(["1m", "1m", "1m", "2m", "2m", "2m",
	                  "3m", "3m", "3m", "7p", "8p", "9p",
			  "西", "西"], "9p");
            var agari_pattern = tehai.getAgariPattern();

            // 三暗刻 or チャンタ
            assertEquals(2, agari_pattern.length);

            for (var i = 0; i < agari_pattern.length; i++) {
                if (agari_pattern[i].tehai.koutsu.length) {
                    // 暗刻がある方が三暗刻
                    assertTrue(MJ.Hantei._2Han.isSanankou(agari_pattern[i]));
                } else {
                    // 暗刻がないならチャンタ
                    assertFalse(MJ.Hantei._2Han.isSanankou(agari_pattern[i]));
                }
            }
        }
    </script>
</head>

<body>
<h1>MJ Tests</h1>

<p>This page contains tests for the JsUnit Framework. To see them, take a look at the source.</p>
</body>
</html>
